<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="所属组" prop="wlGroup">
        <el-select
          v-model="queryParams.wlGroup"
          clearable
          placeholder="请输入所属组"
        >
          <el-option
            v-for="dict in dict.type.work_group_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="处理人" prop="wlHandler">
        <el-input
          v-model="queryParams.wlHandler"
          placeholder="请输入处理人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="级别" prop="wlLevel">
        <el-select
          v-model="queryParams.wlLevel"
          clearable
          placeholder="请输入级别"
        >
          <el-option
            v-for="dict in dict.type.person_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
        <!-- <el-input
          v-model="queryParams.wlLevel"
          placeholder="请输入级别"
          clearable
          @keyup.enter.native="handleQuery"
        /> -->
      </el-form-item>
      <el-form-item label="数据中心" prop="wlDataCenter">
        <el-select
          v-model="queryParams.wlDataCenter"
          placeholder="请选择数据中心"
          clearable
        >
          <el-option
            v-for="dict in dict.type.data_center"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属业务" prop="wlBusiness">
        <el-select
          v-model="queryParams.wlBusiness"
          placeholder="请选择所属业务"
          clearable
        >
          <el-option
            v-for="dict in dict.type.work_load_business"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="工作小时" prop="wlHour">
        <el-input
          v-model="queryParams.wlHour"
          placeholder="请输入工作小时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="申报日期" prop="wlTimestamp">
        <el-date-picker
          clearable
          v-model="queryParams.wlTimestamp"
          type="date"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择处理日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="业务主管" prop="wlSupervisor">
        <el-select
          v-model="queryParams.wlSupervisor"
          placeholder="请选择所属业务"
          clearable
        >
          <el-option
            v-for="supervisor in supervisorList"
            :key="supervisor.value"
            :label="supervisor.label"
            :value="supervisor.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="wlStatus">
        <el-select
          v-model="queryParams.wlStatus"
          placeholder="请选择审核状态"
          clearable
        >
          <el-option
            v-for="dict in dict.type.work_load_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['md:workload:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['md:workload:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['md:workload:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['md:workload:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-user"
          size="mini"
          @click="changeUnWriteDialog(true)"
          v-hasPermi="['md:workload:unwrite:list']"
          >未提交名单</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="workloadList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="申报日期"
        align="center"
        prop="wlTimestamp"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.wlTimestamp, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="id" align="center" prop="wlId" /> -->
      <el-table-column label="所属组" align="center">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.work_group_type"
            :value="scope.row.wlGroup"
          />
        </template>
      </el-table-column>
      <el-table-column label="编写人" align="center" prop="wlHandler" />
      <el-table-column label="审核状态" align="center" prop="wlStatus">
        <template slot-scope="scope">
          <span>{{ showStatus(scope.row.wlStatus) }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="级别" align="center" prop="wlLevel">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.person_level"
            :value="scope.row.wlLevel"
          />
        </template>
      </el-table-column> -->
      <el-table-column label="数据中心" align="center">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.data_center"
            :value="scope.row.wlDataCenter"
          />
        </template>
        <!-- <template slot-scope="scope">
          <span>{{
            formatTableData(scope.row.wlDataCenter, "dataCenterList")
          }}</span>
        </template> -->
      </el-table-column>
      <el-table-column label="所属业务" align="center">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.work_load_business"
            :value="scope.row.wlBusiness"
          />
        </template>
      </el-table-column>
      <!-- <el-table-column label="工作内容" align="center" prop="wlContent" /> -->
      <el-table-column label="工作小时" align="center" prop="wlHour" />

      <el-table-column label="业务主管" align="center" prop="wlSupervisor">
        <template slot-scope="scope">
          <span>{{
            formatTableData(scope.row.wlSupervisor, "supervisorList")
          }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="填写不规范原因" align="center" prop="wlReason" /> -->
      <!-- <el-table-column label="本人是否已修改" align="center" prop="wlModify" /> -->
      <!-- <el-table-column label="证明材料" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDown(scope.row.wlProve)"
            >查阅</el-button
          >
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="备注" align="center" prop="wlTemp" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="120px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-if="scope.row.wlStatus == WORKLOAD_TYPE.update || isCheckUser"
            v-hasPermi="['md:workload:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-check"
            @click="handleCheck(scope.row)"
            v-if="scope.row.wlStatus == WORKLOAD_TYPE.checkPadding"
            v-hasPermi="['md:workload:check']"
            >审核</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-check"
            @click="handleArchived(scope.row)"
            v-hasPermi="['md:workload:archived']"
            >归档</el-button
          > -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['md:workload:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 未填写名单列表 -->
    <un-write-dialog
      :is-open="unWriteDialogOpen"
      :source-data="unWriteList"
      @close="changeUnWriteDialog(false)"
    ></un-write-dialog>

    <!-- 添加或修改工作量对话框 -->
    <el-dialog
      :title="dialogOpt.title"
      inline
      :visible.sync="dialogOpt.open"
      width="1000px"
      append-to-body
    >
      <p v-if="this.form.wlReason && !isDialogCheckStatus" class="tip-reason">
        驳回原因: {{ this.form.wlReason }}
      </p>
      <el-form
        ref="form"
        inline
        :model="form"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="所属组" prop="wlGroup">
          <el-select
            :disabled="isDialogOnlyRead"
            v-model="form.wlGroup"
            placeholder="请输入所属组"
          >
            <el-option
              v-for="dict in dict.type.work_group_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="级别" prop="wlLevel">
          <el-select
            :disabled="isDialogOnlyRead"
            v-model="form.wlLevel"
            placeholder="请输入级别"
          >
            <el-option
              v-for="dict in dict.type.person_level"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="数据中心" prop="wlDataCenter">
          <el-select
            :disabled="isDialogOnlyRead"
            v-model="form.wlDataCenter"
            placeholder="请选择数据中心"
          >
            <el-option
              v-for="item in dict.type.data_center"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="所属业务" prop="wlBusiness">
          <el-select
            :disabled="isDialogOnlyRead"
            v-model="form.wlBusiness"
            placeholder="请选择所属业务"
          >
            <el-option
              v-for="dict in dict.type.work_load_business"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="业务主管" prop="wlSupervisor">
          <el-select
            :disabled="isDialogOnlyRead"
            v-model="form.wlSupervisor"
            placeholder="请选择所属业务"
          >
            <el-option
              v-for="supervisor in supervisorList"
              :key="supervisor.value"
              :label="supervisor.label"
              :value="supervisor.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="工作小时" prop="wlHour">
          <el-input
            :disabled="dialogOpt.type == CHECK_TYPE"
            v-model="form.wlHour"
            placeholder="请输入工作小时"
          />
        </el-form-item>
        <!-- <el-form-item label="备注" prop="wlTemp">
          <el-input v-model="form.wlTemp" placeholder="请输入备注" />
        </el-form-item> -->
        <el-form-item label="申报日期" prop="wlTimestamp">
          <el-date-picker
            clearable
            v-model="form.wlTimestamp"
            :disabled="isDialogOnlyRead || !isCheckUser"
            type="date"
            value-format="timestamp"
            placeholder="请选择处理日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="changeTemp" type="success">{{
            showTemplate ? "关闭" : "模版"
          }}</el-button>
        </el-form-item>
        <template-com
          :list="templateList"
          :is-show="showTemplate"
          @changeText="setContent"
        ></template-com>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工作内容">
              <!-- <editor v-model="form.wlContent" :min-height="192" /> -->
              <el-input
                style="width: 800px"
                type="textarea"
                rows="5"
                ref="contextRel"
                :disabled="isDialogOnlyRead"
                v-model="form.wlContent"
                placeholder="涉及客户敏感信息用【 XX 】代替"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="证明材料" prop="wlProve">
          <file-upload
            v-model="form.wlProve"
            :fileSize="10"
            :fileType="allowfileTypes"
            :limit="5"
          >
          </file-upload>
          <!-- <image-upload
            @onUploaded="handleUploadSuccess"
          ></image-upload> -->
        </el-form-item>
        <el-row>
          <el-form-item
            label="填写不规范原因"
            prop="wlReason"
            v-if="isDialogCheckStatus"
            label-width="110px"
          >
            <el-input
              style="width: 800px"
              v-model="form.wlReason"
              placeholder="请输入填写不规范原因"
            />
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="submitForm"
          v-if="!isDialogCheckStatus"
          >确 定</el-button
        >
        <el-button @click="cancel" v-if="!isDialogCheckStatus">取 消</el-button>
        <el-button
          type="danger"
          @click="handleReject"
          v-if="isDialogCheckStatus"
          >驳回</el-button
        >
        <el-button type="success" @click="handlePass" v-if="isDialogCheckStatus"
          >通过</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listWorkload,
  getWorkload,
  delWorkload,
  addWorkload,
  updateWorkload,
  getUnWriteList,
} from "@/api/md/workload";
import { getUser } from "@/api/system/user";

import { listUser } from "@/api/system/user";

import { listAllWorkshop } from "@/api/mes/md/workshop";
import { getUserProfile } from "@/api/system/user";
import {
  YD_DepId,
  CHECK_TYPE,
  UPDATE_TYPE,
  ADD_TYPE,
  WORKLOAD_TYPE,
  PIGEONHOLE_TYPE,
  TEMPLATE_LIST,
} from "./data.js";
import { formatDate } from "@/utils/index.js";
import FileUpload from "@/components/FileUpload/index";
import ImageUpload from "@/components/ImageUpload";
import TemplateCom from "./TemplateCom.vue";
import UnWriteDialog from "./UnWriteDialog.vue";

export default {
  name: "Workload",
  dicts: [
    "person_level",
    "work_group_type",
    "work_load_business",
    "data_center",
    "work_load_type",
  ],
  components: {
    FileUpload,
    ImageUpload,
    TemplateCom,
    UnWriteDialog,
  },
  computed: {
    isDialogOnlyRead() {
      return this.isDialogCheckStatus;
    },
    /** 弹窗审核状态 */
    isDialogCheckStatus() {
      return this.dialogOpt.type === CHECK_TYPE;
    },
    isCheckUser() {
      const roles = this.$store.getters.roles;
      return roles.includes("work_load_audit") || roles.includes("admin");
    },
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      //数据中心选项
      dataCenterList: [],
      // 工作量表格数据
      workloadList: [],
      dialogOpt: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 状态
        type: "",
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        wlId: null,
        wlGroup: null,
        wlHandler: null,
        wlLevel: null,
        wlDataCenter: null,
        wlBusiness: null,
        wlContent: "",
        wlHour: null,
        wlTimestamp: null,
        wlSupervisor: null,
        wlReason: null,
        wlModify: null,
        wlProve: null,
        wlTemp: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        wlId: [{ required: true, message: "id不能为空", trigger: "blur" }],
        wlTimestamp: [
          { required: true, message: "申报日期不能为空", trigger: "blur" },
        ],
      },
      // 业务主管
      supervisorList: [],
      CHECK_TYPE,
      WORKLOAD_TYPE,
      nickName: "",
      allowfileTypes: ["doc", "xls", "ppt", "txt", "pdf", "png", "jpg", "jpeg"],
      showTemplate: false, // 是否展示模版
      templateList: TEMPLATE_LIST,
      unWriteDialogOpen: false,
      unWriteList: {},
    };
  },
  created() {
    this.init();
    this.getList();
  },
  beforeRouteEnter(to, from, next) {
    if (from.path == "/index") {
      // 首页跳转
      next((vm) => {
        vm.$set(vm.queryParams, "wlStatus", to.query.wlStatus);
      });
    } else {
      // 菜单跳转
      next();
    }
  },
  methods: {
    async init() {
      this.getSupervisorList();
      this.getWorkshops();
      this.getUnWriteList();
    },
    /** 获取用户信息 */
    // getUser() {
    //   getUserProfile().then((response) => {
    //     this.nickName = response.data.nickName;
    //   });
    // },
    showStatus(status) {
      switch (status) {
        case WORKLOAD_TYPE.checkPadding:
        case "0":
          return "待审核";
        case WORKLOAD_TYPE.update:
          return "待修改";
        case WORKLOAD_TYPE.pigeonhole:
          return "归档";
        case WORKLOAD_TYPE.reported:
          return "已上报";
        default:
          return "未知";
      }
    },

    /** 获取业务主管列表 */
    getSupervisorList() {
      const queryParams = {
        pageNum: 1,
        pageSize: 100,
        deptId: YD_DepId,
      };
      listUser(queryParams).then((response) => {
        this.supervisorList = response.rows.map((item) => {
          return {
            value: item.userId,
            label: item.nickName,
          };
        });
      });
    },
    handleUploadSuccess(str) {
      console.log(str);
    },
    /**
     * 获取模版
     */
    changeTemp() {
      this.showTemplate = !this.showTemplate;
    },
    /** 设置弹窗状态 */
    setDialog(opt) {
      this.dialogOpt.title = opt.title;
      this.dialogOpt.open = opt.open;
      this.dialogOpt.type = opt.type;
    },
    /** 格式化表格数据 */
    formatTableData(val, arrName) {
      const res = this[arrName].find((item) => item.value == val);
      return res?.label || "";
    },
    /** 查询工作量列表 */
    getList() {
      this.loading = true;
      if (!this.isCheckUser) {
        this.queryParams.wlHandler = this.$store.getters.nickName;
      }
      listWorkload(this.queryParams).then((response) => {
        this.workloadList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.queryParams.wlHandler = "";
      });
    },
    // 获取数据中心
    getWorkshops() {
      listAllWorkshop().then((response) => {
        this.dataCenterList = response.data.map((item) => {
          return {
            value: item.workshopId,
            label: item.workshopName,
          };
        });
      });
    },
    // 取消按钮
    cancel() {
      this.setDialog({ open: false });
      this.reset();
    },
    handleDown(row) {
      console.log(row);
    },
    // 表单重置
    reset() {
      const wlLevelDef =
        this.$store.getters.userLevel || this.dict.type.person_level[0].value;
      this.form = {
        wlId: null,
        wlGroup: null,
        wlHandler: null,
        wlLevel: wlLevelDef,
        wlDataCenter: null,
        wlBusiness: null,
        wlContent: "",
        wlHour: 8,
        wlTimestamp: new Date().getTime(),
        wlSupervisor: null,
        wlReason: null,
        wlModify: null,
        wlProve: null,
        wlTemp: null,
        wlStatus: WORKLOAD_TYPE.checkPadding, // A 待审核 B
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 审核按钮操作 */
    handleCheck(row) {
      this.reset();
      const wlId = row.wlId || this.ids;
      getWorkload(wlId).then((response) => {
        this.form = response.data;
        this.setDialog({
          open: true,
          title: "审核工作量",
          type: CHECK_TYPE,
        });
      });
    },
    /** 归档按钮操作 */
    handleArchived(row) {
      this.reset();
      const wlId = row.wlId || this.ids;
      getWorkload(wlId).then((response) => {
        this.form = response.data;
        this.setDialog({
          open: true,
          title: "归档工作量",
          type: PIGEONHOLE_TYPE,
        });
      });
    },
    setContent(text) {
      this.form.wlContent = text;
      this.$refs.contextRel.focus();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.wlId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.setDialog({
        open: true,
        title: "添加工作量",
        type: ADD_TYPE,
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const wlId = row.wlId || this.ids;
      getWorkload(wlId).then((response) => {
        this.form = response.data;
        this.form.wlTimestamp = new Date(this.form.wlTimestamp).getTime();
        this.setDialog({
          open: true,
          title: "修改工作量",
          type: UPDATE_TYPE,
        });
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.wlId != null) {
            // 临时性状态管理 待审核
            this.form.wlStatus = WORKLOAD_TYPE.checkPadding;
            updateWorkload(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.setDialog({ open: false });
              this.getList();
            });
          } else {
            addWorkload(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.setDialog({ open: false });
              this.getList();
            });
          }
        }
      });
    },
    /** 通过按钮 */
    handlePass() {
      // 临时性状态管理 待审核
      this.form.wlStatus = WORKLOAD_TYPE.pigeonhole;
      this.form.wlReason = "";
      updateWorkload(this.form).then((response) => {
        this.$modal.msgSuccess("审核通过");
        this.setDialog({ open: false });
        this.getList();
      });
    },
    /** 驳回按钮 */
    handleReject() {
      if (this.form.wlReason) {
        // 临时性状态管理 待审核
        this.form.wlStatus = WORKLOAD_TYPE.update;

        updateWorkload(this.form).then((response) => {
          this.$modal.msgSuccess("已驳回");
          this.setDialog({ open: false });
          this.getList();
        });
      } else {
        this.$modal.msgError("请填写驳回原因");
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const wlIds = row.wlId || this.ids;
      const delStr = row
        ? `是否确认【${row.wlHandler}】的【${row.wlTimestamp}】的工作量数据？`
        : `是否确认【${this.ids.length}】条的工作量数据？`;
      this.$modal
        .confirm(delStr)
        .then(function () {
          return delWorkload(wlIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "mes/md/workload/export",
        {
          ...this.queryParams,
        },
        `工作量_${new Date().getTime()}.xlsx`
      );
    },
    changeUnWriteDialog(type) {
      this.unWriteDialogOpen = type;
    },
    async getUnWriteList() {
      const res = await getUnWriteList();
      if (res.code == 200) {
        this.unWriteList = res.data.reduce((prev, cur) => {
          const person = {
            deptName: cur.dept.deptName,
            depId: cur.dept.deptId,
            nickName: cur.nickName,
            phonenumber: cur.phonenumber,
          };

          if (!prev[person.depId]) {
            prev[person.depId] = {
              deptName: person.deptName,
              person: [],
            };
          }

          prev[person.depId].person.push(person);

          return prev;
        }, {});

        console.log(this.unWriteList);
      } else {
        this.$modal.msgError("未填写名单异常");
      }
      console.log("unlist", res);
    },
  },
};
</script>

<style lang="scss" scoped>
.tip-reason {
  color: red;
  font-size: 18px;
  font-weight: bold;
}
.dialog-footer {
  text-align: center;
}
</style>
